package com.example.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.Mapper.publiMapper;

/**
 * 一个帮助类
 * @author Administrator
 *
 */
@Service
public class publi {
   
	@Autowired
	publiMapper mapper; 
	
	/**
	 * 一个单号
	 * @param 当前日期 格式 'yyyy-MM-dd'
	 * @param 表名
	 * @param 列名
	 * @return
	 */
	  public  String  danhao(String dangqianriqi,String biaming,String lie){
		  String hh=dangqianriqi.replace("-","");  
          String sql="select max("+lie+") from "+biaming+" where "+lie+" like '"+hh+"%'";
		  System.out.println(sql);
          String danhao=mapper.danhao(sql); 
           System.out.println(danhao);
	         if(danhao==null){ 
	        	 System.out.println(hh);
	        	 danhao=hh+"001";
	         }else{
	        	 Long k=Long.parseLong(danhao);
	        	  k++;
	        	  danhao=k.toString();
	         }
		    return danhao;
	  }
	   
}
